#!/bin/sh

PATH=/sbin:/bin:/usr/bin:/usr/sbin:%OPTWARE_TARGET_PREFIX%/bin:%OPTWARE_TARGET_PREFIX%/sbin

mkdir -p %OPTWARE_TARGET_PREFIX%/etc/oww -m 755

# Move any existing setup files
if ! test -e %OPTWARE_TARGET_PREFIX%/etc/oww/setupNG
then
	if test -e %OPTWARE_TARGET_PREFIX%/share/setupNG
	then 
		mv %OPTWARE_TARGET_PREFIX%/share/setupNG %OPTWARE_TARGET_PREFIX%/etc/oww
	fi
fi

if ! test -e %OPTWARE_TARGET_PREFIX%/etc/oww/devices
then
	if test -e %OPTWARE_TARGET_PREFIX%/share/devices
	then  
		mv %OPTWARE_TARGET_PREFIX%/share/devices %OPTWARE_TARGET_PREFIX%/etc/oww
	fi
fi

if ! test -e %OPTWARE_TARGET_PREFIX%/etc/oww/stats
then
	if test -e %OPTWARE_TARGET_PREFIX%/share/stats
	then  
		mv %OPTWARE_TARGET_PREFIX%/share/stats %OPTWARE_TARGET_PREFIX%/etc/oww
	fi
fi

echo ; echo
echo "Oww (owwnogui) has been installed."

if ! test -e %OPTWARE_TARGET_PREFIX%/etc/oww/devices
then
echo "Set up your devices interactively by running owwnogui -i"
echo "Then quit and run %OPTWARE_TARGET_PREFIX%/etc/init.d/S80oww"
else
echo "Devices were already configured."
echo "Go ahead and run %OPTWARE_TARGET_PREFIX%/etc/init.d/S80oww"
fi
echo

